package com.example.app.resources;

import com.example.app.domain.repository.ElementRepository;
import com.google.gson.Gson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/data", produces = "application/json;charset=UTF-8")
@Api(tags = "数据获取demo", value = "数据获取")
@Slf4j
public class DataResource {
    @Autowired
    ElementRepository elementRepository;
    private Gson gson = new Gson();

    @GetMapping("/source")
    @ApiOperation(value = "获取原始数据", notes = "备注")
    @ResponseBody
    public String getSourceData() {
        return gson.toJson(elementRepository.getAllSourceData());
    }

    @GetMapping("/calculated")
    @ResponseBody
    @ApiOperation(value = "获取计算后的数据", notes = "备注")
    public String getOutputData() {
        return gson.toJson(elementRepository.getAllOutputData());
    }
}
